<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ph="http://java.sun.com/jsf/composite/cashTransaction">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">




                <h:form>

                    <p:panel header="DRAWER Adjustment" 
                             rendered="#{!drawerAdjustmentController.printPreview}">
                        <h:panelGrid columns="2" >
                            <h:panelGrid columns="2">
                                <h:outputLabel value="Drawer" ></h:outputLabel>
                                <p:autoComplete   forceSelection="true"  id="acStock"
                                                  value="#{drawerAdjustmentController.drawer}"                                                  
                                                  completeMethod="#{drawerController.completeDrawer}" 
                                                  var="i" itemLabel="#{i.name}" itemValue="#{i}" >
                                    <p:column headerText="Drawer Name">
                                        <h:outputLabel value="#{i.name}" ></h:outputLabel>
                                    </p:column>
                                    <p:column headerText="Cash Vale">
                                        <h:outputLabel value="#{i.runningBallance}" >
                                            <f:convertNumber pattern="#,##0.00"/> 
                                        </h:outputLabel>
                                    </p:column>
                                    <p:column headerText="Cheque Value">
                                        <h:outputLabel value="#{i.chequeBallance}" >
                                            <f:convertNumber pattern="#,###" />
                                        </h:outputLabel>
                                    </p:column>
                                    <p:column headerText="Slip Value">
                                        <h:outputLabel value="#{i.slipBallance}" >
                                            <f:convertNumber pattern="#,###" />
                                        </h:outputLabel>
                                    </p:column>
                                    <p:column headerText="Credit Card Value">
                                        <h:outputLabel value="#{i.creditCardBallance}" >
                                            <f:convertNumber pattern="#,###" />
                                        </h:outputLabel>
                                    </p:column>
                                    <f:ajax event="itemSelect" execute="@this" render="det"/>
                                </p:autoComplete>

                                <h:outputLabel value="New Cash Vale"/>
                                <p:inputText autocomplete="off" value="#{drawerAdjustmentController.cashTransaction.cashValue}" >
                                    <f:convertNumber pattern="#,##0.00"/> 
                                </p:inputText>
                                <h:outputLabel value="New Cheque Value"/>
                                <p:inputText autocomplete="off" value="#{drawerAdjustmentController.cashTransaction.chequeValue}" >
                                    <f:convertNumber pattern="#,###" />
                                </p:inputText>
                                <h:outputLabel value="Slip Value"/>                                
                                <p:inputText autocomplete="off" value="#{drawerAdjustmentController.cashTransaction.slipValue}" >
                                    <f:convertNumber pattern="#,###" />
                                </p:inputText>
                                <h:outputLabel value="Credit Card Value"/>                                
                                <p:inputText autocomplete="off" value="#{drawerAdjustmentController.cashTransaction.creditCardValue}" >
                                    <f:convertNumber pattern="#,###" />
                                </p:inputText>
                                <h:outputLabel value="Comment" ></h:outputLabel>
                                <p:inputTextarea value="#{drawerAdjustmentController.comment}" ></p:inputTextarea>

                                <p:commandButton value="Make Adjustment" ajax="false" 
                                                action="#{drawerAdjustmentController.saveAdjustBill()}" />
                                <p:commandButton ajax="false" action="#{drawerAdjustmentController.makeNull()}"
                                                 value="New Adjustment"/>
                            </h:panelGrid>

                            <h:panelGrid columns="2" id="det">
                                <f:facet name="header">
                                    <h:outputLabel value="DRAWER DETAIL"/>
                                </f:facet>

                                <h:outputLabel value="Drawer Name"/>
                                <h:outputLabel value="#{drawerAdjustmentController.drawer.name}" />
                                <h:outputLabel value="Cash Vale"/>
                                <h:outputLabel value="#{drawerAdjustmentController.drawer.runningBallance}" >
                                    <f:convertNumber pattern="#,##0.00"/> 
                                </h:outputLabel>
                                <h:outputLabel value="Cheque Value"/>
                                <h:outputLabel value="#{drawerAdjustmentController.drawer.chequeBallance}" >
                                    <f:convertNumber pattern="#,###" />
                                </h:outputLabel>
                                <h:outputLabel value="Slip Value"/>                                
                                <h:outputLabel value="#{drawerAdjustmentController.drawer.slipBallance}" >
                                    <f:convertNumber pattern="#,###" />
                                </h:outputLabel>
                                <h:outputLabel value="Credit Card Value"/>                                
                                <h:outputLabel value="#{drawerAdjustmentController.drawer.creditCardBallance}" >
                                    <f:convertNumber pattern="#,###" />
                                </h:outputLabel>


                            </h:panelGrid>
                        </h:panelGrid>
                    </p:panel>

                    <p:panel rendered="#{drawerAdjustmentController.printPreview}">
                        <p:commandButton ajax="false" action="#{drawerAdjustmentController.makeNull()}" value="New Adjustment"/>
                        <ph:adjustmentDrawer bill="#{drawerAdjustmentController.adjustmentBill}" />
                    </p:panel>

                </h:form>

            </ui:define>


        </ui:composition>

    </h:body>
</html>
